package com.legna.mhxy.support.controller;

import com.legna.mhxy.support.entity.User;
import com.legna.mhxy.support.service.LoginService;
import com.legna.mhxy.support.utils.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@Tag(name="登录")
@RestController
@RequestMapping("/login")
@AllArgsConstructor
public class LoginController {

    private final LoginService loginService;

    @PostMapping("/login")
    @Operation(summary = "登录")
    public Result<User> login(@RequestParam(value = "login") String login,
                                     @RequestParam(value = "pwd") String pwd) throws IOException {
        User user = loginService.login(login,pwd);
        return Result.ok(user);
    }
}
